package com.tianya.portal.blog.controller;

import com.tianya.common.web.core.domain.AjaxResult;
import com.tianya.common.web.core.page.TableDataInfo;
import com.tianya.portal.blog.domain.BlogNoteMenu;
import com.tianya.portal.blog.service.IBlogNoteMenuService;
import com.tianya.portal.common.core.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 博客笔记菜单Controller
 *
 * @author tianya
 * @date 2023-04-30
 */
@RestController
@RequestMapping("/noteMenu")
public class BlogNoteMenuController extends BaseController {
    @Autowired
    private IBlogNoteMenuService blogNoteMenuService;

    /**
     * 查询博客笔记菜单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BlogNoteMenu blogNoteMenu) {
        startPage();
        List<BlogNoteMenu> list = blogNoteMenuService.selectBlogNoteMenuList(blogNoteMenu);
        return getDataTable(list);
    }

    /**
     * 获取博客笔记菜单详细信息
     */
    @GetMapping(value = "/detail/{menuId}")
    public AjaxResult getInfo(@PathVariable("menuId") String menuId) {
        return success(blogNoteMenuService.selectBlogNoteMenuByMenuId(menuId));
    }


    @GetMapping("/menuTree")
    public AjaxResult areaTree() {
        return success(blogNoteMenuService.selectMenuTreeList());
    }

    /**
     * 刷新博客笔记菜单树结构
     *
     * @return 结果
     */
    @GetMapping(value = "/refresh")
    public AjaxResult refresh() {
        blogNoteMenuService.refresh();
        return AjaxResult.success();
    }
}
